
// 渲染数据
 $(function () {
     getUserInfo();
     getDaturmInfo();
 });

function getUserInfo(){
    var b_id = common.get('id');
    $('#repayment_href').attr('href','/order/spaymentplan?id='+b_id);
    var datas = {
        interface:'users@upUserInfo',
        b_id:b_id, 
    };
    common.ajax({
        data: datas,
        success: function (data) {
            if (data.status == '2000') {
                if(data.result.userInfo.u_true_name){
                    $('#userinfo').html(common.formatTemplate(data.result.userInfo,$('#userinfo').html()));
                }
                if (data.result.orderInfo.b_period) {
                    $('#fenqiinfo').html(common.formatTemplate(data.result.orderInfo, $('#fenqiinfo').html()));
                }
                if (data.result.orderInfo.month_rent_amt) {
                    $('#paymentinfo').html(common.formatTemplate(data.result.orderInfo, $('#paymentinfo').html()));
                }
                if(data.result.orderInfo.p_return_type == 4){
                    $('#paymentinfo').css('height','4.8rem');
                    $('.xy_month').html('<span class="ban-l fl" style="width:4rem;line-height: 1.2rem;">前'+data.result.orderInfo.p_x_month+'月每月应交</span><span class="ban-r" style="width: 40%">'+data.result.orderInfo.x_month_pay+'元</span>');
                    $('.xy_month').after('<div class="ban1 line"><span class="ban-l fl" style="width:4rem;line-height: 1.2rem;">后'+data.result.orderInfo.p_y_month+'月每月应交</span><span class="ban-r" style="width: 40%">'+data.result.orderInfo.y_month_pay+'元</span></div>');
                }
            } else if (data.status == '5000') {
                falert(data.msg);
            }
        }
    });
}

function getDaturmInfo(){
    var datas = {
        interface:'users@userContact',
        b_id:common.get('id')
    };
    common.ajax({
        data: datas,
        success: function (data) {
            if (data.status == '2000') {
                if(data.result){
                    var html = '';
                    if(data.result.length <= 2){
                        $(".banner4").css("height","6rem");
                    }
                    $.each(data.result, function(i, o) { 
                        html += '<div class="rent fl" id="img'+o.ud_type+'">';
                        html += '<img class="picture" src="'+o.ud_url+'" alt="">';
                        html += '<div >'+o.ud_name+'</div>';
                        html += '</div>';
                    });
                    $('#yxzlTabInfo').html(html);
                }
                if(data.result == 0){
                    $(".banner4").css('display','none');
                }
            } else if (data.status == '5000') {
                falert(data.msg);
            }
        }
    });
}